﻿using System.Linq;
using NUnit.Framework;
using StreetPacMan.Server.Facade;

namespace StreetPacMan.Server.Tests.Integ
{
    [TestFixture]
    public class GameCreated : BddBase
    {
        private readonly GetGameStateResult GameInstance;
        private readonly IServerFacade ServerFacade;

        public GameCreated()
        {
            ServerFacade = ServerFacadeFactory.GetServerFacade();
            ServerFacade.CreateGameX("GameName");
            GameInstance = ServerFacade.GetGameStateAsObvserverX("GameName");
        }

        [Test]
        public void GameStateShouldBeCreated()
        {
            Assert.AreEqual(GameState.Created, GameInstance.State);
        }

        [Test]
        public void OnObserverPlayerShouldExist()
        {
            Assert.AreEqual(PlayerRole.Observer, GameInstance.Players.Single().Role);
        }

        [Test]
        public void OneEventOfGameCreatedShouldExists()
        {
            Assert.AreEqual(EventType.GameCreated, ServerFacade.GetAllEventsX("GameName").Events.Single().Type);
        }
    }
}